<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    <div style="display: flex; align-items: center;justify-content: space-around;padding: 16px">
        <wu-plus-checkbox-group value="['测试1']" id="checkoutBoxGroup">
            <wu-plus-checkbox label="测试1" style="margin-right: 8px"></wu-plus-checkbox>
            <wu-plus-checkbox label="测试2" style="margin-right: 8px"></wu-plus-checkbox>
            <wu-plus-checkbox label="测试3"></wu-plus-checkbox>
        </wu-plus-checkbox-group>
    </div>


    <div style="display: flex; align-items: center;justify-content: space-around;padding: 16px">
        <wu-plus-checkbox label="测试4" style="margin-right: 8px" indeterminate="true" id="indeterminate2"></wu-plus-checkbox>
        <wu-plus-checkbox-group value="['测试1']" id="checkoutBoxGroup2">
            <wu-plus-checkbox label="测试1" style="margin-right: 8px"></wu-plus-checkbox>
            <wu-plus-checkbox label="测试2" style="margin-right: 8px"></wu-plus-checkbox>
            <wu-plus-checkbox label="测试3"></wu-plus-checkbox>
        </wu-plus-checkbox-group>
    </div>
</div>
</body>
</html>
<script type="module">
    let _groupIndex = 0
    const _groupValueList = [["测试1", "测试2"], ["测试1", "测试3"], ["测试1"], ["测试3"]]
    // 代码有些啰嗦，简单实现关联多选框选择
    const indeterminate = document.getElementById("indeterminate2");
    const checkoutBoxGroup = document.getElementById("checkoutBoxGroup2");
    indeterminate.addEventListener('change', (e) => {
        console.log(e.detail);
        if (e.detail.value) {
            console.log("全选")
            checkoutBoxGroup.setAttribute("value", JSON.stringify(['测试1', '测试2', '测试3']))
            indeterminate.setAttribute("checked", 'true')
        } else {
            indeterminate.setAttribute("indeterminate", false)
            checkoutBoxGroup.setAttribute("value", [])
            indeterminate.setAttribute("checked", false)
        }
    })
    checkoutBoxGroup.addEventListener("change", (e) => {
        const value = checkoutBoxGroup.getAttribute("value");
        if (value.length === 0) {
            indeterminate.setAttribute("indeterminate", false)
            indeterminate.setAttribute("checked", false);
            return
        }
        if (value.length < 3) {
            indeterminate.setAttribute("indeterminate", true)
            return;
        }
        if (value.length === 3) {
            indeterminate.setAttribute("indeterminate", false)
            indeterminate.setAttribute("checked", true)
        }

    })
</script>
